/**
 * @author: h'zh
 * @date: 12.14
 */

//TODO:适配各种向后端发出的请求(登录&注册时操作)

import request from "../utils/request";
export function login(username, password, userType) {
    return request({
        url: '/user/login',
        method: 'post',
        data: {
            username,
            password,
            userType
        }
    });
}

/**
 * 这里定义注册数据的传输
 * */
export function signup(username, password,userType,name,sex,address,qq,tel) {
    return request({
        url: '/user/signup',
        method: 'post',
        data: {
            username,
            password,
            userType,
            name,
            sex,
            address,
            qq,
            tel,
        }
    });
}

export function logout() {
    return request({
        url: '/user/logout',
        method: 'post'
    })
}

/**
 * @description 获取用户的基本信息，例如权限(可以查看的页面等)
 * @returns {AxiosPromise}
 */
export function getUserInfo() {
  return request({
    url: '/user/info',
    method: 'get'
  })
}

/**
 * @description 修改用户密码
 */
export function modifyPwd(username, oldPassword, newPassword, userType){
    return request({
        url: '/user/modifyPwd',
        method: 'post',
        data: {
            username,
            oldPassword,
            newPassword,
            userType
        }
    });
}
